home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Drivers / ghostHPDJ / gs_init.ps < prev    next >
Encoding:
Text File  |  1994-09-13  |  27.8 KB  |  908 lines

  1. %    Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % Initialization file for the interpreter.
  20. % When this is run, systemdict is still writable.
  21.  
  22. % Comment lines of the form
  23. %    %% Replace <n> <file(s)>
  24. % indicate places where the next <n> lines should be replaced by
  25. % the contents of <file(s)>, when creating a single merged init file.
  26.  
  27. % NOTE: This is a special version of gs_init.ps, which is adapted for use
  28. % on NeXTstep. I've modified the character translation table for the NeXT 
  29. % PostScript character set! (Peter.Pflaeging@magwien.gv.at)
  30.  
  31. % Check the interpreter revision.  NOTE: the interpreter code requires
  32. % that the first non-comment token in this file be an integer.
  33. %
  34. 261
  35. dup revision ne
  36.  { (gs: Interpreter revision \() print revision 10 string cvs print
  37.    (\) does not match gs_init.ps revision \() print 10 string cvs print
  38.    (\).\n) print flush 1 .quit
  39.  }
  40. if pop
  41.  
  42. % Define true and false.
  43. systemdict begin
  44. /true 0 0 eq def
  45. /false 0 1 eq def
  46. end
  47.  
  48. % Acquire userdict.
  49. currentdict dup 200 .setmaxlength        % userdict
  50. systemdict begin
  51. /userdict exch def
  52.  
  53. % Acquire the debugging flags.
  54. currentdict /DEBUG known   /DEBUG exch def
  55.   /VMDEBUG
  56.     DEBUG {{print ( ) print vmstatus pop (      ) cvs print pop ( ) print
  57.             systemdict length (      ) cvs print (\n) print flush}}
  58.       {{pop}} ifelse
  59.   def
  60. currentdict /DISKFONTS known   /DISKFONTS exch def
  61. currentdict /ESTACKPRINT known   /ESTACKPRINT exch def
  62. currentdict /NOBIND known   /NOBIND exch def
  63. /.bind /bind load def
  64. NOBIND { /bind { } def } if
  65. currentdict /NOCACHE known   /NOCACHE exch def
  66. currentdict /NODISPLAY known   not /DISPLAYING exch def
  67. currentdict /NOPAUSE known   /NOPAUSE exch def
  68. currentdict /NOPLATFONTS known   /NOPLATFONTS exch def
  69. currentdict /OUTPUTFILE known    % obsolete
  70.  { /OutputFile /OUTPUTFILE load def
  71.    currentdict /OUTPUTFILE undef
  72.  } if
  73. currentdict /QUIET known   /QUIET exch def
  74. currentdict /SAFER known   /SAFER exch def
  75. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  76.  
  77. % Acquire environment variables.
  78. currentdict /DEVICE known not
  79.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  80.  
  81. QUIET not { (Initializing... ) print flush } if
  82.  
  83. (START) VMDEBUG
  84.  
  85. % Acquire the standard files.
  86. /.stdin (%stdin) (r) file def
  87. /.stdout (%stdout) (w) file def
  88. /.stderr (%stderr) (w) file def
  89.  
  90. % Turn on array packing for the rest of initialization.
  91. true setpacking
  92.  
  93. % Define a procedure for skipping over an unneeded section of code.
  94. % This avoids allocating space for the skipped procedures.
  95. /.skipeof    % string ->
  96.  { { dup currentfile =string readline pop eq { exit } if } loop pop
  97.  } bind def
  98.  
  99. % Define a special version of def for making operator procedures.
  100. /odef
  101.     {1 index exch .makeoperator def} bind def
  102.  
  103. % Define predefined procedures substituting for operators,
  104. % in alphabetical order.
  105.  
  106. userdict /#copies 1 put
  107. /[    /mark load def
  108. /]     {counttomark array astore exch pop} odef
  109. /abs    {dup 0 lt {neg} if} odef
  110. /copypage
  111.     { 1 false .outputpage
  112.       (>>copypage, press <return> to continue<<\n) .confirm
  113.     } odef
  114. /defaultmatrix
  115.     {currentdevice exch deviceinitialmatrix} odef
  116. /.echo /echo load def
  117. userdict /.echo.mode true put
  118. /echo    {dup /.echo.mode exch store .echo} odef
  119. /eexec
  120.     { 55665 .filter_eexecDecode
  121.       cvx systemdict begin stopped
  122.       % Only pop systemdict if it is still the top element,
  123.       % because this is apparently what Adobe interpreters do.
  124.       currentdict systemdict eq { end } if
  125.       { stop } if
  126.     } bind def
  127. /executive
  128.     { { prompt
  129.         { (%statementedit) (r) file } stopped { exit } if
  130.         cvx execute
  131.       } loop
  132.     } odef
  133. /framedevice
  134.     {.stderr (Warning: framedevice is an obsolete operator.\n) writestring
  135.      .stderr flushfile
  136.      pop pop pop setmatrix initclip} odef
  137. /handleerror
  138.     {errordict /handleerror get exec} bind def
  139. /identmatrix
  140.     {{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} odef
  141. /initgraphics
  142.     {initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
  143.      [] 0 setdash 0 setgray 10 setmiterlimit} odef
  144. /initmatrix
  145.     {.tempmatrix defaultmatrix setmatrix} odef
  146. /languagelevel 1 def        % we don't have full Level 2
  147. /matrix    {6 array identmatrix} odef
  148. /prompt    {flush flushpage
  149.      (GS) print count 0 ne
  150.       {(<) print count =only}
  151.      if (>) print flush} bind def
  152. /pstack    {0 1 count 3 sub {index ==} for} def
  153. /quit    {0 .quit} odef
  154. /run    {dup type /filetype eq
  155.       { true }
  156.       { findlibfile { exch pop true } { false } ifelse }
  157.      ifelse
  158.       {cvx execute}
  159.       {(r) file}        % let the error happen
  160.      ifelse} odef
  161. /showpage
  162.     { #copies true .outputpage
  163.       (>>showpage, press <return> to continue<<\n) .confirm
  164.       erasepage initgraphics
  165.     } odef
  166. % Code output by Adobe Illustrator relies on the fact that
  167. % `stack' is a procedure, not an operator!!!
  168. /stack    {0 1 count 3 sub {index =} for} bind def
  169. /start    { executive } def
  170. % This interpreter is compatible with PostScript "version" 54.0 (I think).
  171. /version (54.0) def
  172.  
  173. % Provide semi-fake but usable definitions for some of
  174. % the color PostScript extensions.
  175. /setcolorscreen {
  176.     setscreen 9 {pop} repeat
  177. } odef
  178. /currentcolorscreen {
  179.     currentscreen 3 copy 6 copy
  180. } odef
  181.  
  182. % Define some additional built-in procedures (beyond the ones defined by
  183. % the PostScript Language Reference Manual).
  184. % Warning: these are not guaranteed to stay the same from one Ghostscript
  185. % release to the next!
  186.  
  187. /concatstrings
  188.     { exch dup length 2 index length add string    % str2 str1 new
  189.       dup dup 4 2 roll copy        % str2 new new new1
  190.       length 4 -1 roll putinterval
  191.     } bind def
  192. /copyarray
  193.     { dup length array copy } bind def
  194. /copystring
  195.     { dup length string copy } bind def
  196. /.dicttomark        % (the Level 2 >> operator)
  197.     { counttomark 2 idiv dup dict begin
  198.        { def } repeat pop currentdict end
  199.     } bind def
  200. /finddevice
  201.     { systemdict /devicedict get exch get } bind def
  202. /.growdict        % grow a dictionary
  203.     { dup length 3 mul 2 idiv 1 add .setmaxlength
  204.     } bind def
  205. /.growput        % put, grow the dictionary if needed
  206.     { 2 index length 3 index maxlength eq
  207.        { 3 copy pop known not { 2 index .growdict } if
  208.        } if
  209.       put
  210.     } bind def
  211. /selectdevice
  212.     { finddevice setdevice } bind def
  213. /signalerror        % object errorname
  214.     { errordict exch get exec } bind def
  215.  
  216. % Define =string, which is used by some PostScript programs even though
  217. % it isn't documented anywhere.
  218. /=string 128 string def
  219.  
  220. % Define the =[only] procedures.  Also define =print,
  221. % which is used by some PostScript programs even though
  222. % it isn't documented anywhere.
  223. /=    { =only (\n) print } bind def
  224. /=only    { { =string cvs } stopped { pop pop (--nostringval--) } if print } bind def
  225. /=print    /=only load def
  226. % Temporarily define == as = for the sake of run0.
  227. /== /= load def
  228.  
  229. % Define the filter operator.
  230.  
  231. /.filterstring (.filter_01234567890123456789) def
  232. /.filterstring1 .filterstring 8 .filterstring length 8 sub getinterval def
  233. /filter
  234.     { //.filterstring exch 0 exch
  235.       //.filterstring1 cvs length 8 add getinterval cvn load exec
  236.     } odef
  237. systemdict /.filter_LZWEncode undef    % per FSF
  238.  
  239. % Define procedures for getting and setting the current device resolution.
  240.  
  241. /gsgetdeviceprop
  242.  { 1 index getdeviceprops
  243.     { 1 index counttomark 1 add index eq { exit } if pop pop } loop
  244.    dup mark eq        % if true, not found
  245.     { pop dup /undefined signalerror }
  246.     { counttomark 1 add 1 roll cleartomark exch pop exch pop }
  247.    ifelse
  248.  } bind def
  249. /gscurrentresolution
  250.  { currentdevice /HWResolution gsgetdeviceprop
  251.  } bind def
  252. /gssetresolution
  253.  { 2 array astore mark exch /HWResolution exch
  254.    currentdevice copydevice putdeviceprops setdevice
  255.  } bind def
  256.  
  257. % Define auxiliary procedures needed for the above.
  258. /shellarguments        % -> shell_arguments true (or) false
  259.     { /ARGUMENTS where
  260.        { /ARGUMENTS get dup type /arraytype eq
  261.           { aload pop /ARGUMENTS null store true }
  262.           { pop false }
  263.          ifelse }
  264.        { false } ifelse
  265.     } bind def
  266. /.confirm
  267.     {DISPLAYING NOPAUSE not and
  268.       {% Print a message and wait for the user to type something.
  269.        % If the user just types a newline, flush it.
  270.        print flush
  271.        .echo.mode false echo
  272.          .stdin dup read
  273.          {dup (\n) 0 get eq {pop pop} {unread} ifelse} {pop} ifelse
  274.        echo}
  275.       {pop} ifelse} bind def
  276. /.identmatrix        % a read-only identity matrix
  277.     matrix readonly def
  278. /.tempmatrix        % a temporary matrix
  279.     matrix def
  280.  
  281. % Define the procedure used by the C executive for executing user input,
  282. % and also by the run operator.
  283. % This is called with a procedure or file on the operand stack.
  284. /execute
  285.     {stopped $error /newerror get and {handleerror} if} odef
  286. % Define an execute analogue of run0.
  287. /execute0
  288.     {stopped $error /newerror get and {handleerror flush 1 .quit} if} bind def
  289.  
  290. % Define a special version of `run' that aborts on errors.
  291. /run0
  292.     { dup /.currentfilename exch def
  293.        { findlibfile not { stop } if }
  294.       stopped
  295.        { (Can't find initialization file ) print
  296.          .currentfilename == flush 1 .quit
  297.        } if
  298.       exch pop cvx stopped
  299.        { (While reading ) print .currentfilename print (:\n) print flush
  300.          handleerror 1 .quit
  301.        } if
  302.     } bind def
  303. % Temporarily substitute it for the real `run'.
  304. /.run /run load def
  305. /run /run0 load def
  306.  
  307. % If we want a "safer" system, disable some obvious ways to cause havoc.
  308. SAFER not { (%END SAFER) .skipeof } if
  309. /file
  310.  { dup (r) eq
  311.     { file }
  312.     { /invalidfileaccess signalerror }
  313.    ifelse
  314.  } bind odef
  315. /renamefile { /invalidfileaccess signalerror } odef
  316. /deletefile { /invalidfileaccess signalerror } odef
  317. %END SAFER
  318.  
  319. % Create the error handling machinery.
  320. % The interpreter has created the ErrorNames array.
  321. % Define $error.
  322. /$error 11 dict def        % newerror, errorname, command, errorinfo,
  323.                 % ostack, estack, dstack, recordstacks,
  324.                 % binary, .inerror, position
  325. $error begin
  326.   /newerror false def
  327.   /recordstacks true def
  328.   /binary false def
  329.   /.inerror false def
  330.   /position null def
  331. end
  332. % Define errordict.  It has one entry per error name,
  333. %   plus handleerror and .printerror.
  334. /errordict ErrorNames length 2 add dict def
  335. % Define the standard error handlers.  When they are invoked,
  336. % the top element of the o-stack is the error name;
  337. % the next element is the offending command.
  338. errordict begin
  339.   { //$error /.inerror get .instopped not or
  340.      { (Unrecoverable error: ) print =only flush
  341.        ( in ) print = flush
  342.        count 0 gt
  343.         { (Operand stack:\n  ) print
  344.       0 1 count 3 sub { (  ) print index =only flush } for
  345.       (\n) print flush
  346.     } if
  347.        1 .quit
  348.      } if    % detect error recursion
  349.     $error /.inerror true put
  350.     $error /newerror true put
  351.     $error exch /errorname exch put
  352.     $error exch /command exch put
  353.     $error /dstack undef
  354.     $error /estack undef
  355.     $error /ostack undef
  356.     $error /recordstacks get $error /errorname get /VMerror ne and
  357.      { $error /dstack countdictstack array dictstack put
  358.        $error /estack countexecstack array execstack put
  359.        count array astore dup $error exch /ostack exch put
  360.      aload pop
  361.      } if
  362.     $error /position currentfile status
  363.      { errordict /ioerror get
  364.        errordict /ioerror { pop stop } put
  365.        currentfile { fileposition } stopped { pop null } if
  366.        errordict /ioerror 4 -1 roll put
  367.      }
  368.      { null
  369.      }
  370.     ifelse put
  371.     $error /.inerror false put
  372.     stop
  373.   } bind
  374.   ErrorNames
  375.    { [ 1 index 3 index /exec load ] cvx def
  376.    } forall
  377.   pop
  378. end
  379. % Define the standard handleerror.  We break out the printing procedure
  380. % (.printerror) so that it can be extended for binary output
  381. % if the Level 2 facilities are present.
  382. errordict begin
  383.   /.printerror
  384.    { (Error: ) print
  385.      $error begin
  386.        errorname ==only flush
  387.        ( in ) print
  388.        /command load ==only flush
  389.        currentdict /ostack known
  390.         { (\nOperand stack:\n  ) print ostack { (  ) print ==only } forall
  391.     } if
  392.        currentdict /estack known
  393.         { (\nExecution stack:\n  ) print
  394.       estack { (  ) print ESTACKPRINT { ==only } { =only } ifelse } forall
  395.     } if
  396.        currentdict /dstack known
  397.     { (\nDictionary stack:\n  ) print dstack
  398.        { dup (  ) print length =only (/) print maxlength =only } forall
  399.     } if
  400.        (\n) print
  401.        errorname /VMerror eq
  402.         { (VM status:) print mark vmstatus
  403.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  404.       cleartomark (\n) print
  405.     } if
  406.        position null ne
  407.     { (Current file position is ) print position = }
  408.        if
  409.        /newerror false def
  410.      end
  411.      flush
  412.    } bind def
  413.   /handleerror
  414.    { errordict /.printerror get exec
  415.      .instopped {stop} if
  416.    } bind def
  417. end
  418.  
  419. % Define the [write]==[only] procedures.
  420. /==    {==only (\n) print} bind def
  421. /==only    {.stdout exch write==only} bind def
  422. /write==
  423.     {2 copy write==only pop (\n) writestring} bind def
  424. /.dict 16 dict dup
  425. begin def
  426.   /.cvp {=string cvs .p} bind def
  427. % /.f {the_output_file} def
  428.   /.nop {(-) .p type .cvp (-) .p} bind def
  429.   /.p {.f exch writestring} bind def
  430.   /.print
  431.     {dup type .dict exch known
  432.      {dup type exec} {.nop} ifelse
  433.     } bind def
  434.   /integertype /.cvp load def
  435.   /nulltype { pop (null) .p } bind def
  436.   /realtype /.cvp load def
  437.   /booleantype /.cvp load def
  438.   /nametype
  439.     {dup xcheck not {(/) .p} if
  440.      dup length =string length gt
  441.       {dup length string}
  442.       {=string}
  443.      ifelse cvs .p} bind def
  444.   /arraytype
  445.     {dup rcheck
  446.       {dup xcheck {(})({)} {(])([)} ifelse .p
  447.        exch () exch
  448.        {exch .p .print ( )} forall pop .p}
  449.       {.nop}
  450.      ifelse} bind def
  451.   /operatortype
  452.       {(--) .p .cvp (--) .p} bind def
  453.   /packedarraytype /arraytype load def
  454. % /.ch {a_character} def
  455.   /stringtype
  456.     {dup rcheck
  457.       {(\() .p
  458.        {dup dup 32 lt exch 127 ge or
  459.         {(\\) .p 8#1000 add 8 =string cvrs 1 3 getinterval .p}
  460.         {dup dup -2 and 40 eq exch 92 eq or {(\\) .p} if
  461.          .f exch write}
  462.         ifelse}
  463.        forall (\)) .p}
  464.       {.nop}
  465.      ifelse} bind def
  466. {//.dict begin exch cvlit /.f exch def .print end}
  467.   bind cvx
  468. end
  469. /write==only exch def
  470.  
  471. (END PROCS) VMDEBUG
  472.  
  473. % Define the font directory.
  474. % Make it big to leave room for transformed fonts.
  475. /FontDirectory 100 dict def
  476.  
  477. % Define the standard encoding vector.
  478. /StandardEncoding
  479. % \00x
  480.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  481.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  482.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  483.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  484. % \04x
  485.     /space /exclam /quotedbl /numbersign
  486.     /dollar /percent /ampersand /quoteright
  487.     /parenleft /parenright /asterisk /plus
  488.     /comma /hyphen /period /slash
  489.     /zero /one /two /three
  490.     /four /five /six /seven
  491.     /eight /nine /colon /semicolon
  492.     /less /equal /greater /question
  493. % \10x
  494.     /at /A /B /C /D /E /F /G
  495.     /H /I /J /K /L /M /N /O
  496.     /P /Q /R /S /T /U /V /W
  497.     /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  498. % \14x
  499.     /quoteleft /a /b /c /d /e /f /g
  500.     /h /i /j /k /l /m /n /o
  501.     /p /q /r /s /t /u /v /w
  502.     /x /y /z /braceleft /bar /braceright /asciitilde /.notdef
  503. % \20x
  504.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  505.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  506.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  507.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  508. % \24x
  509.     /.notdef /exclamdown /cent /sterling
  510.     /fraction /yen /florin /section
  511.     /currency /quotesingle /quotedblleft /guillemotleft
  512.     /guilsinglleft /guilsinglright /fi /fl
  513.     /.notdef /endash /dagger /daggerdbl
  514.     /periodcentered /.notdef /paragraph /bullet
  515.     /quotesinglbase /quotedblbase /quotedblright /guillemotright
  516.     /ellipsis /perthousand /.notdef /questiondown
  517. % \30x (192-)
  518.     /onesuperior /grave /acute /circumflex /tilde /macron /breve /dotaccent
  519.     /dieresis /twosuperior /ring /cedilla /threesuperior /hungarumlaut 
  520.     /ogonek /caron /emdash /plusminus /onequarter /onehalf /threequarters 
  521.     /agrave /aacute /acircumflex /atilde /adieresis /aring /ccedilla /egrave 
  522.     /eacute /ecircumflex /edieresis
  523. % \34x (224-)
  524.     /igrave /AE /iacute /ordfeminine /icircumflex /idieresis /eth /ntilde
  525.     /Lslash /Oslash /OE /ordmasculine /ograve /oacute /ocircumflex /otilde
  526.     /odieresis /ae /ugrave /uacute /ucircumflex /dotlessi /udieresis /yacute
  527.     /lslash /oslash /oe /germandbls /thorn /ydieresis /.notdef /.notdef
  528. 256 packedarray def
  529. 0 StandardEncoding .registerencoding
  530.  
  531. % Define the ISO Latin-1 encoding vector.
  532. % The first half is the same as the standard encoding,
  533. % except for minus instead of hyphen at code 055.
  534. /ISOLatin1Encoding
  535. StandardEncoding 0 45 getinterval aload pop
  536.     /minus
  537. StandardEncoding 46 82 getinterval aload pop
  538. %*** NOTE: the following are missing in the Adobe documentation,
  539. %*** but appear in the displayed table:
  540. %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
  541. % \20x
  542.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  543.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  544.     /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
  545.     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  546. % \24x
  547.     /space /exclamdown /cent /sterling
  548.     /currency /yen /brokenbar /section
  549.     /dieresis /copyright /ordfeminine /guillemotleft
  550.     /logicalnot /hyphen /registered /macron
  551.     /degree /plusminus /twosuperior /threesuperior
  552.     /acute /mu /paragraph /periodcentered
  553.     /cedilla /onesuperior /ordmasculine /guillemotright
  554.     /onequarter /onehalf /threequarters /questiondown
  555. % \30x
  556.     /Agrave /Aacute /Acircumflex /Atilde
  557.     /Adieresis /Aring /AE /Ccedilla
  558.     /Egrave /Eacute /Ecircumflex /Edieresis
  559.     /Igrave /Iacute /Icircumflex /Idieresis
  560.     /Eth /Ntilde /Ograve /Oacute
  561.     /Ocircumflex /Otilde /Odieresis /multiply
  562.     /Oslash /Ugrave /Uacute /Ucircumflex
  563.     /Udieresis /Yacute /Thorn /germandbls
  564. % \34x
  565.     /agrave /aacute /acircumflex /atilde
  566.     /adieresis /aring /ae /ccedilla
  567.     /egrave /eacute /ecircumflex /edieresis
  568.     /igrave /iacute /icircumflex /idieresis
  569.     /eth /ntilde /ograve /oacute
  570.     /ocircumflex /otilde /odieresis /divide
  571.     /oslash /ugrave /uacute /ucircumflex
  572.     /udieresis /yacute /thorn /ydieresis
  573. 256 packedarray def
  574. 1 ISOLatin1Encoding .registerencoding
  575.  
  576. % Define stubs for the Symbol and Dingbats encodings.
  577. userdict begin
  578. %% Replace 3 (gs_sym_e.ps)
  579.   /SymbolEncoding
  580.    { userdict begin (gs_sym_e.ps) run /SymbolEncoding load end
  581.    } bind def
  582. %% Replace 3 (gs_dbt_e.ps)
  583.   /DingbatsEncoding
  584.    { userdict begin (gs_dbt_e.ps) run /DingbatsEncoding load end
  585.    } bind def
  586. end
  587.  
  588. (END FONTDIR/ENCS) VMDEBUG
  589.  
  590. % Construct a dictionary of all available devices.
  591. mark
  592.     % Loop until the getdevice gets a rangecheck.
  593.   0 { {dup getdevice exch 1 add} loop} stopped pop
  594.   dict /devicedict exch def
  595.   devicedict begin        % 2nd copy of count is on stack
  596.    { dup /Name gsgetdeviceprop cvn dup 3 -1 roll def
  597.      counttomark 1 roll
  598.    } repeat
  599.   end
  600. ] /devicenames exch def
  601. $error /newerror false put        % remove error indication
  602.  
  603. (END DEVS) VMDEBUG
  604.  
  605. % Define statusdict, for the benefit of programs
  606. % that think they are running on a LaserWriter or similar printer.
  607. %% Replace 1 (gs_statd.ps)
  608. (gs_statd.ps) run
  609.  
  610. (END STATD) VMDEBUG
  611.  
  612. % Load the standard font environment.
  613. %% Replace 1 (gs_fonts.ps)
  614. (gs_fonts.ps) run
  615.  
  616. (END GS_FONTS) VMDEBUG
  617.  
  618. % Load the initialization files for optional features.
  619. %% Replace 4 INITFILES
  620. systemdict /INITFILES known
  621.  { INITFILES { dup run VMDEBUG } forall
  622.  }
  623. if
  624.  
  625. % If Level 2 functionality is implemented, enable it now.
  626. /.setlanguagelevel where { pop 2 .setlanguagelevel } if
  627.  
  628. % Create a null font.  This is the initial font.
  629. 8 dict dup begin
  630.   /FontMatrix [ 1 0 0 1 0 0 ] def
  631.   /FontType 3 def
  632.   /FontName () def
  633.   /Encoding StandardEncoding def
  634.   /FontBBox { 0 0 0 0 } def    % executable is bogus, but customary ...
  635.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  636.   /PaintType 0 def        % shouldn't be needed!
  637. end
  638. /NullFont exch definefont setfont
  639. % Define NullFont as the font, but remove it from FontDirectory.
  640. /NullFont currentfont def
  641. FontDirectory /NullFont undef
  642.  
  643. (END FONTS) VMDEBUG
  644.  
  645. % Restore the real definition of run.
  646. /run /.run load def
  647. currentdict /.run undef
  648.  
  649. % Bind all the operators defined as procedures.
  650. /.bindoperators        % binds operators in currentdict
  651.  { % Temporarily disable the typecheck error.
  652.    errordict /typecheck errordict /typecheck get
  653.    errordict /typecheck { pop } put    % pop the command
  654.    currentdict
  655.     { dup type /operatortype eq
  656.        { % This might be a real operator, so bind might cause a typecheck,
  657.      % but we've made the error a no-op temporarily.
  658.      .bind        % do a real bind even if NOBIND is set
  659.        }
  660.       if pop pop
  661.     } forall
  662.    put
  663.  } def
  664. NOBIND not { .bindoperators } if
  665.  
  666. % Establish a default environment.
  667.      
  668. DISPLAYING not
  669.  { nulldevice (%END DISPLAYING) .skipeof
  670.  } if
  671. /defaultdevice 0 getdevice systemdict /DEVICE known
  672.  { pop devicedict DEVICE known not
  673.     { (Unknown device: ) print DEVICE =
  674.       flush 1 .quit
  675.     }
  676.    if DEVICE finddevice
  677.  }
  678. if def
  679. defaultdevice
  680. systemdict /DEVICEWIDTH known
  681. systemdict /DEVICEHEIGHT known or
  682. systemdict /DEVICEWIDTHPOINTS known or
  683. systemdict /DEVICEHEIGHTPOINTS known or
  684. systemdict /DEVICEXRESOLUTION known or
  685. systemdict /DEVICEYRESOLUTION known or
  686. systemdict /PAPERSIZE known or
  687. not { (%END DEVICE) .skipeof } if
  688. systemdict /PAPERSIZE known
  689.  {    % Convert the paper size to device dimensions.
  690.    true statusdict /.pagetypenames get
  691.     { PAPERSIZE eq
  692.        { PAPERSIZE load
  693.          dup 0 get /DEVICEWIDTHPOINTS exch def
  694.          1 get /DEVICEHEIGHTPOINTS exch def
  695.          pop false exit
  696.        }
  697.       if
  698.     }
  699.    forall
  700.     { (Unknown paper size: ) print PAPERSIZE ==only (.\n) print
  701.     }
  702.    if
  703.  }
  704. if
  705. % Adjust the device parameters per the command line.
  706.    getdeviceprops .dicttomark begin
  707.    6 dict begin
  708.    /dw HWSize 0 get def
  709.    /dh HWSize 1 get def
  710.    /dmat InitialMatrix def
  711.    /dxres HWResolution 0 get def
  712.    /dyres HWResolution 1 get def
  713.    /DEVICEXRESOLUTION where
  714.     { pop /drq DEVICEXRESOLUTION dxres div def
  715.       0 2 4
  716.        { dup
  717.      dmat exch get drq mul
  718.      dmat 3 1 roll put
  719.        }
  720.       for
  721.       dw drq mul round cvi /dw exch def
  722.       /dxres DEVICEXRESOLUTION def
  723.     }
  724.    if
  725.    /DEVICEYRESOLUTION where
  726.     { pop /drq DEVICEYRESOLUTION dyres div def
  727.       1 2 5
  728.        { dup
  729.          dmat exch get drq mul
  730.      dmat 3 1 roll put
  731.        }
  732.       for
  733.       dh drq mul round cvi /dh exch def
  734.       /dyres DEVICEYRESOLUTION def
  735.      }
  736.    if
  737.     % Check for device sizes specified in pixels.
  738.    /DEVICEWIDTH where
  739.     { pop /dw DEVICEWIDTH def
  740.     }
  741.    if
  742.    /DEVICEHEIGHT where
  743.     { pop /dh DEVICEHEIGHT def
  744.     }
  745.    if
  746.     % Check for device sizes specified in points.
  747.    /DEVICEWIDTHPOINTS where
  748.     { pop /dw DEVICEWIDTHPOINTS dxres mul 72 div round cvi def
  749.     }
  750.    if
  751.    /DEVICEHEIGHTPOINTS where
  752.     { pop /dh DEVICEHEIGHTPOINTS dyres mul 72 div round cvi def
  753.     }
  754.    if
  755.    mark
  756.    /HWSize [ dw dh ] /HWResolution [ dxres dyres ] /InitialMatrix dmat
  757.    defaultdevice putdeviceprops
  758.    end end
  759. %END DEVICE
  760. % Set any device properties defined on the command line.
  761. dup getdeviceprops
  762. counttomark 2 idiv
  763.  { systemdict 2 index known
  764.     { pop dup load counttomark 2 roll }
  765.     { pop pop }
  766.    ifelse
  767.  } repeat
  768. systemdict /BufferSpace known
  769. systemdict /MaxBitmap known not and
  770.  { /MaxBitmap BufferSpace
  771.  } if
  772. counttomark dup 0 ne
  773.  { 2 add -1 roll putdeviceprops }
  774.  { pop pop }
  775. ifelse
  776. setdevice        % does an erasepage
  777. %END DISPLAYING
  778.  
  779. % Set the graphics state parameters that initgraphics doesn't initialize.
  780. 1 setflat
  781. { } setblackgeneration
  782. { pop 0 } setundercolorremoval
  783.  
  784. (END DEVICE) VMDEBUG
  785.  
  786. % Establish a default upper limit in the character cache,
  787. % namely, enough room for a 1/4" x 1/4" character at the resolution
  788. % of the default device, or for 3 x the "average" character size,
  789. % whichever is larger.
  790. mark
  791.     % Compute limit based on character size.
  792.   18 18 dtransform        % 1/4" x 1/4"
  793.   exch abs cvi 31 add 32 idiv 4 mul    % X raster
  794.   exch abs cvi mul        % Y
  795.     % Compute limit based on allocated space.
  796.   cachestatus 5 2 roll pop pop pop pop div 3 mul cvi exch pop
  797.   max dup 10 idiv exch
  798. setcacheparams
  799. % Conditionally disable the character cache.
  800. NOCACHE { 1 setcachelimit } if
  801.  
  802. (END CONFIG) VMDEBUG
  803.  
  804. % Establish an appropriate halftone screen.
  805.  
  806. 72 72 dtransform abs exch abs min    % min(|dpi x|,|dpi y|)
  807. dup 150 lt systemdict /DITHERPPI known not and
  808.  {        % Low-res device, use ordered dither spot function
  809.     % The following 'ordered dither' spot function was contributed by
  810.     % Gregg Townsend.  Thanks, Gregg!
  811.   16.001 div 0            % not 16: avoids rounding problems
  812.    { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  813.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  814.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  815.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  816.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  817.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  818.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  819.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  820.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  821.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  822.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  823.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  824.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  825.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  826.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  827.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  828.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  829.    > exch get 256 div }        % screen
  830.   { }        % transfer
  831.   true        % strokeadjust
  832.  }
  833.  {        % Hi-res device, use 45 degree dot spot function.
  834.     % 46 seems to be a good frequency value for printers
  835.     % between 200 and 400 DPI.  We set the frequency low enough
  836.     % that we can be guaranteed at least a 4x4 pixel cell.
  837.    systemdict /DITHERPPI known { DITHERPPI } { 46 } ifelse
  838.    exch 4.01 div min
  839.    45
  840.     % The following screen algorithm is used by permission of the author.
  841.     { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos 
  842.       1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  843.     }        % screen
  844.     % Set the transfer function to lighten up the grays.
  845.     % We correct at the high end so that very light grays
  846.     % don't disappear completely if they darken <1 screen pixel.
  847.    { sqrt dup dup 0.9375 gt exch 0.995 lt and    % > 15/16
  848.       { currentscreen pop pop
  849.         gsave initmatrix 72 exch div dup dtransform grestore
  850.     cvi exch cvi mul abs        % # of pixels in halftone cell
  851.     1 sub                % tweak to avoid boundary
  852.     1 exch div 1 exch sub min
  853.       }
  854.      if
  855.    }
  856.    false    % strokeadjust
  857.  }
  858. ifelse
  859.   5 -3 roll bind setscreen
  860.   exch settransfer
  861.   /setstrokeadjust where { pop setstrokeadjust } { pop } ifelse
  862. initgraphics
  863. % The interpreter relies on there being at least 2 entries
  864. % on the graphics stack.  Establish the second one now.
  865. gsave
  866.  
  867. % Define some control sequences as no-ops.
  868. % This is a hack to get around problems
  869. % in some common PostScript-generating applications.
  870. (\004) cvn { } def        % Apple job separator
  871. (\004\004) cvn { } def        % two of the same
  872. (\033) cvn { } def        % MS Windows LaserJet IV prologue
  873. (\004\033) cvn { } def        % MS Windows LaserJet IV epilogue
  874.  
  875. % Turn off array packing for interactive use.
  876. false setpacking
  877.  
  878. % Close up systemdict.
  879. end
  880. WRITESYSTEMDICT not { systemdict readonly pop } if
  881.  
  882. (END INIT) VMDEBUG
  883.  
  884. % Print the welcome message.
  885.  
  886. QUIET { (%END WELCOME) .skipeof } if
  887.  
  888. (done.\n) print flush
  889.  
  890. product print
  891. ( ) print revision 10 idiv 10 div =only
  892. revision 10 mod (.) print =only
  893. ( \() print revisiondate 100 idiv 100 mod =only
  894. (/) print revisiondate 100 mod =only
  895. (/) print revisiondate 10000 idiv =only
  896. (\)\n) print copyright print
  897. (  All rights reserved.\n) print
  898. product (Ghostscript) eq
  899.  { (Ghostscript comes with NO WARRANTY: see the file COPYING for details.\n) print
  900.  }
  901. if
  902.  
  903. flush
  904.  
  905. %END WELCOME
  906.  
  907. % The interpreter will run the initial procedure (start).
  908.